import useAxiosInstance from "../util/config.ts";
import {CommonModel} from "../interface/commonModel.ts";
import {NAMESPACE_MENU} from "../interface/menu.ts";

export const queryMenu = async (options:NAMESPACE_MENU.MenuQuery):Promise<CommonModel.ApiResponse>=>{
    let res = await useAxiosInstance<NAMESPACE_MENU.MenuItem,any>({
        url:"/menu/list",
        params:options
    });
    return res.data
}

export const createMenu= async (options:NAMESPACE_MENU.MenuBase):Promise<CommonModel.ApiResponse>=>{
    let res = await useAxiosInstance.post("/menu/create",options)
    return res.data
}

export const updateMenu = async (options:NAMESPACE_MENU.MenuItem):Promise<CommonModel.ApiResponse>=>{
    let res = await useAxiosInstance.post("/menu/update",options)
    return res.data
}

export const deleteMenu = async (ids:Array<number|string>):Promise<CommonModel.ApiResponse>=>{
    let res = await useAxiosInstance.post("/menu/delete",{ids:ids});
    return res.data
}